<?php
namespace App\Http\Requests\User;

use App\Http\Requests\Request;
use Illuminate\Validation\Rule;

/**
 * 添加/编辑认证信息
 *
 * @package App\Http\Requests\User
 * @author zx
 * @date 2019-01-25
 */
class AddAuthRequest extends Request {

    public function rules():array
    {
        return [
            'user_id' => 'required|integer',
            'realname' => 'required|between:1,15',
            'id_card' => [
                'required',
                "regex:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/"
            ],
            'sex' => [
                "required",
                Rule::in(["男", "女"])
            ],
            'nation' => 'required',
            'brith' => 'required',
            'address' => 'required',
            'term' => 'required',
            'lssue' => 'required',
            'card_image_just' => 'required',
            'card_image_back' => 'required'
        ];
    }

    public function messages()
    {
        return [
            'user_id.required' => '参数必须',
            'user_id.integer' => '参数格式错误',
            'realname.required' => '姓名必须',
            'realname.between' => '姓名长度错误',
            'id_card.required' => '身份证号码必须',
            'id_card.required' => '身份证号码格式错误',
            'sex.required' => '性别必须',
            'sex.in' => '性别格式错误',
            'nation.required' => '民族必须',
            'brith.required' => '出生年月必须',
            'address.required' => '地址必须',
            'term.required' => '有效期限必须',
            'lssue.required' => '签发必须',
            'card_image_just.required' => '身份证正面必须',
            'card_image_back.required' => '身份证反面必须'
        ]; // TODO: Change the autogenerated stub
    }

}